/****************************************************************
 * <strong>MFPageManager虚拟化数据分页</strong>
 *
 * <p>
 *MFPageManager虚拟化数据分页
 * </p>
 *
 * @author AndyZhang 2011 cnet2001@163.com
 * @version 0.1
 * ToDo:2011-11-29 
 ***************************************************************/

package com.thinkwide.data.ormapping.datatable;

public class MFPageManager {
    private int totalRowCount;
    private int totalPageCount;
    private int pageIndex;
    private int pageRowCount;

    public MFPageManager() {

    }

    public MFPageManager(int totalRowCount, int pageRowCount) {
        this.totalRowCount = totalRowCount;
        this.pageRowCount = pageRowCount;
        totalPageCount = (int) Math.ceil((float) totalRowCount / pageRowCount);
    }

    public int getNextPage() {
        return (pageIndex - 1) > 0 ? pageIndex - 1 : 1;
    }

    public int getPrevPage() {
        return (pageIndex + 1) <= totalPageCount ? pageIndex + 1 : totalPageCount;
    }

    public int getFirstPage() {
        return 1;
    }

    public int getLastPage() {
        return totalPageCount;
    }

    public void countPage(int totalRowCount, int pageRowCount) {
        this.totalRowCount = totalRowCount;
        this.pageRowCount = pageRowCount;
        totalPageCount = (int) Math.ceil((float) totalRowCount / pageRowCount);
    }

    public void setTotalRowCount(int totalRowCount) {
        this.totalRowCount = totalRowCount;
    }

    public int getTotalRowCount() {
        return totalRowCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageRowCount(int pageRowCount) {
        this.pageRowCount = pageRowCount;
    }

    public int getPageRowCount() {
        return pageRowCount;
    }
}
